import { BasicColumn, FormSchema } from '@apps/antd-admin/src/components/Table';
import { goodsList } from '@apps/ant-bus/src/views/business/goods/goods/api';
import {render} from "@apps/antd-admin/src/hooks/render/renderUtils";
export const columns: BasicColumn[] = [
  {
    title: '订单编号',
    dataIndex: 'orderNo',
    width: 160,
  },
  {
    title: '商品名称',
    dataIndex: 'goodsName',
    width: 160,
  },
  {
    title: '商品图片',
    dataIndex: 'coverImg',
    customRender: render.renderImage,
    width: 160,
  },
  {
    title: '兑换码',
    dataIndex: 'orderCode',
    width: 160,
  },
  {
    title: '兑换人',
    dataIndex: 'nickName',
    width: 100,
  },
  {
    title: '兑换人手机号',
    dataIndex: 'mobile',
    width: 100,
  },

  {
    title: '消耗积分',
    dataIndex: 'totalPrice',
    width: 100,
  },
  {
    title: '兑换日期',
    dataIndex: 'createTime',
    width: 150,
  }
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'orderNo',
    label: '订单编号',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'mobile',
    label: '手机号',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'orderStatus',
    label: '订单状态',
    component: 'Select',
    colProps: { span: 4 },
    componentProps: {
      options: [
        { label: '待付款', value: 1 },
        { label: '已付款', value: 2 },
        { label: '已退款', value: 3 },
        { label: '申请退款中', value: 4 },
        { label: '已关闭', value: 5 },
      ],
    },
  },
  {
    field: 'startDate',
    label: '开始日期',
    component: 'DatePicker',
    colProps: { span: 4 },
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
  {
    field: 'endDate',
    label: '结束日期',
    component: 'DatePicker',
    colProps: { span: 4 },
    componentProps: {
      valueFormat: 'YYYY-MM-DD',
      format: 'YYYY-MM-DD',
    },
  },
];

export const formSchema: FormSchema[] = [
  {
    label: '商品',
    field: 'goodsId',
    component: 'ApiSelect',
    required: true,
    componentProps: {
      api: goodsList,
      labelField: 'goodsName',
      valueField: 'goodsId',
      immediate: true,
      showSearch: true,
    },
  },
  {
    label: '订单金额',
    field: 'totalPrice',
    component: 'InputNumber',
    required: true,
  },
  {
    label: '用户备注',
    field: 'remark',
    component: 'InputTextArea',
    required: false,
  },
];
